if(Shopify.customerPrivacy){consentTrackingLoaded();}else{if("loadFeatures"in window.Shopify){window.Shopify.loadFeatures([{name:"consent-tracking-api",version:"0.1"}],consentTrackingLoaded)}else{consentTrackingLoaded();}} function consentTrackingLoaded(){const userConsent=(Shopify?.customerPrivacy?.currentVisitorConsent||(()=>{return{analytics:"yes",marketing:"yes",preferences:"yes",sale_of_data:"yes"}}))();function executeAnalyticsTracking(){function injectScript(url,async,defer){{let adnabu_s=document.createElement('script');adnabu_s.type='text/javascript';adnabu_s.async=async;adnabu_s.defer=defer;adnabu_s.src=url;let adnabu_x=document.getElementsByTagName('script')[0];adnabu_x.parentNode.insertBefore(adnabu_s,adnabu_x);}} function convertToUrl(adnabuParams){{return url=Object.keys(adnabuParams).map(function(k){{return k+'='+adnabuParams[k];}}).join('&');}} function makeAjaxCall(url,parseJson,callback){{let adnabuXhttp=new XMLHttpRequest();if(callback){{adnabuXhttp.onreadystatechange=function(){{if(this.readyState===XMLHttpRequest.DONE){{if(parseJson){{callback(JSON.parse(this.response));}}else{{callback(this.response);}}}}}};}} adnabuXhttp.open("GET",url,true);adnabuXhttp.send();}} function formatDate(date){{let adnabu_d=new Date(date),adnabuMonth=''+(adnabu_d.getMonth()+1),adnabuDay=''+adnabu_d.getDate(),adnabuYear=adnabu_d.getFullYear();if(adnabuMonth.length<2)adnabuMonth='0'+adnabuMonth;if(adnabuDay.length<2)adnabuDay='0'+adnabuDay;return[adnabuYear,adnabuMonth,adnabuDay].join('-');}} let adnabuFormat='shopify_MX__';function loadScript(url,callback){var script=document.createElement('script');script.type='text/javascript';script.src=url;script.onreadystatechange=callback;script.onload=callback||(()=>{});document.head.appendChild(script);} loadScript('https://www.googletagmanager.com/gtag/js?id=AW-573500487');window.dataLayer=window.dataLayer||[];function gtag(){{dataLayer.push(arguments);}} gtag('js',new Date());gtag('config','AW-573500487');function getProductInfo(adnabuProduct,adnabuParams){let adnabuProductId=adnabuFormat.replace('',adnabuProduct.id),adnabuVariantId=adnabuParams.variant,adnabuVariant,adnabuPrice;if(adnabuVariantId){let adnabuVariantMap={};let adnabu_x;for(adnabu_x of adnabuProduct.variants){adnabuVariantMap[adnabu_x.id]=adnabu_x;} adnabuVariant=adnabuVariantMap[adnabuVariantId];} if(adnabuVariant===undefined&&adnabuProduct.variants.length>0){let adnabuIds=[],adnabuTotalPrice=0,adnabu_v;for(adnabu_v of adnabuProduct.variants){adnabuIds.push(adnabuProductId.replace('',adnabu_v.id).replace('',adnabu_v.sku));adnabuTotalPrice+=parseFloat(adnabu_v.price);} return{'id':adnabuIds,'price':adnabuTotalPrice/adnabuProduct.variants.length}}else if(adnabuVariant!==undefined){return{'id':adnabuProductId.replace('',adnabuVariant.id).replace('',adnabuVariant.sku),'price':adnabuVariant.price};} return{'id':adnabuProductId,'price':adnabuProduct.price};} function getProductIdFromItem(item){const{product_id,sku,variant_id}=item;return adnabuFormat.replace('',product_id).replace('',sku??'').replace('',variant_id??'');} let adnabuBodyClass=document.getElementsByTagName('body')[0].getAttribute('class');let adnabuTemplate;if(adnabuBodyClass){let adnabuTemplateClass=adnabuBodyClass.match(/[\w-]*template[\w-]*/g);if(adnabuTemplateClass){adnabuTemplate=adnabuTemplateClass[0].replace('template-','');}} let adnabuPageType=typeof(ShopifyAnalytics)!=='undefined'?ShopifyAnalytics.meta.page.pageType:'';let gtagCustomParameters;if(adnabuTemplate=='cart'||location.href.includes('/cart')){makeAjaxCall('/cart.json',true,function(response){let adnabuCart=response;let adnabuProductIds=adnabuCart.items.map(function(item){return getProductIdFromItem(item);});gtagCustomParameters={ecomm_prodid:adnabuProductIds,ecomm_pagetype:'cart',ecomm_totalvalue:adnabuCart.total_price/100};gtag('event','page_view',gtagCustomParameters);});}else if(adnabuTemplate=='product'||adnabuPageType=='product'||location.href.includes('/products')){makeAjaxCall('/products/'+window.location.pathname.split('/products/')[1]+'.json',true,function(response){let adnabuProduct=response.product;let adnabuParams={},adnabu_v,adnabu_x;for(adnabu_x of decodeURIComponent(window.location.search.substring(1)).split('&')){let adnabuQuery=adnabu_x.split('=');adnabuParams[adnabuQuery[0]]=adnabuQuery[1];} let adnabuProductInfo=getProductInfo(adnabuProduct,adnabuParams);gtagCustomParameters={ecomm_prodid:adnabuProductInfo.id,ecomm_pagetype:'product',ecomm_category:adnabuProduct.product_type,ecomm_totalvalue:adnabuProductInfo.price};gtag('event','page_view',gtagCustomParameters);});}else{if(adnabuTemplate=='collection'||adnabuPageType=='collection'||location.href.includes('/collections')){let collectionPath=window.location.pathname;gtagCustomParameters={ecomm_pagetype:'home',ecomm_category:collectionPath.replace('/collections/','')};}else if(adnabuTemplate=='index'||adnabuPageType=='home'){gtagCustomParameters={ecomm_pagetype:'home'};}else if(adnabuTemplate=='search'||adnabuPageType=='search'||location.href.includes('/search')){gtagCustomParameters={ecomm_pagetype:'search'};}else{gtagCustomParameters={ecomm_pagetype:'other'};} gtag('event','page_view',gtagCustomParameters);}} const initialTrackingState=["yes",""].includes(userConsent?.analytics);function userConsentTracking(){if(initialTrackingState){executeAnalyticsTracking();}} userConsentTracking();document.addEventListener("visitorConsentCollected",(event)=>{if(event.detail?.analyticsAllowed&&!initialTrackingState){executeAnalyticsTracking();}});document.addEventListener('trackingConsentAccepted',()=>{if(!initialTrackingState){userConsentTracking();}});}